package com.esunrising.esungsc.common.generator;

import java.util.Optional;

public enum EsunFieldType {
    VARCHAR("VARCHAR2", "String"),
    CHAR("CHAR", "String"),
    INT("INT", "Integer"),
    INTEGER("INTEGER", "Integer"),
    DATETIME("DATETIME", "LocalDateTime"),
    DATE("DATE", "LocalDateTime"),
    TIMESTAMP("TIMESTAMP", "LocalDateTime"),
    TEXT("TEXT", "String"),
    LONGTEXT("LONGTEXT", "String"),
    NUMBER("NUMBER", "Double"),
    DECIMAL("DECIMAL", "BigDecimal");


    private String dbType;
    private String javaType;

    EsunFieldType(String dbType, String javaType){
        this.dbType = dbType;
        this.javaType = javaType;
    }

    public static Optional<EsunFieldType> of(String dbType){
        for(EsunFieldType fieldType:EsunFieldType.values()){
            if(fieldType.getDbType().equals(dbType)){
                return Optional.of(fieldType);
            }
        }
        return Optional.empty();
    }

    public String getDbType() {
        return dbType;
    }

    public void setDbType(String dbType) {
        this.dbType = dbType;
    }

    public String getJavaType() {
        return javaType;
    }

    public void setJavaType(String javaType) {
        this.javaType = javaType;
    }
}